package cn.wolfcode.controller;

import cn.wolfcode.domain.Region;
import cn.wolfcode.domain.Strategy;
import cn.wolfcode.domain.StrategyCatalog;
import cn.wolfcode.domain.Travel;
import cn.wolfcode.service.*;
import cn.wolfcode.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationController {
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService catalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    public Object hotRegion(){
        List<Region> regions = regionService.queryHotRegion();
        System.out.println(regions);
        return JsonResult.success(regions);
    }

    @GetMapping("/search")
    public Object search(String regionId){
        return JsonResult.success(destinationService.queryDestByRegionIdForApi(regionId));
    }

    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = catalogService.queryCatalogByDestId(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/toasts")
    public Object toasts(String destId){
        return JsonResult.success(destinationService.queryToasts(destId));

    }

    @GetMapping("/strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        List<Strategy> list = strategyService.queryViewnumTop3(destId);
        return JsonResult.success(list);

    }

    @GetMapping("/travel/viewnumTop3")
    public Object travelViewnumTop3(String destId){
        List<Travel> list = travelService.queryViewnumTop3(destId);
        return JsonResult.success(list);

    }
}
